package org.coc.betterchicago;

import org.coc.betterchicago.rest.ErrorResource;
import org.coc.betterchicago.rest.UserInfoResource;
import org.restlet.Application;
import org.restlet.Restlet;
import org.restlet.routing.Router;

public class RestApi extends Application {
	@Override
	public synchronized Restlet createRoot() {
		// Create a router Restlet that routes each call to a new Resource
		Router router = new Router(getContext());

		router.attach("", ErrorResource.class);
		router.attach("/error", ErrorResource.class);
		router.attach("/user/{id}", UserInfoResource.class);
		return router;
	}

}

// Restlet mainpage = new Restlet() {
// @Override
// public void handle(Request request, Response response) {
// try {
// JSONObject json = new JSONObject();
// json.put("success", false);
// json.put("error", "Service not available");
//
// JsonRepresentation jsonRep = new JsonRepresentation(json);
// response.setEntity(jsonRep);
// } catch (JSONException e) {
// response.setEntity(new StringRepresentation("{\"success\" : false, \"error\": \"Service not available\"}", MediaType.APPLICATION_JSON));
// }
// }
// };
